package com.spider.service;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import org.apache.hadoop.hbase.client.Result;

import com.spider.dao.HBaseDAOImp;
import com.spider.dao.HBaseDao;
import com.spider.utils.JsoupUtils;
import com.spider.utils.ResolveHtmlUtils;

public class ResolveHtmlTest {
	private List<String> idList;
	private List<String> diffList;
	private List<String> answUrlList;
	
	private List<String> contList;
	private List<String> imgUrlList;
	private List<List<String>> contentList;
	private HBaseDao dao = new HBaseDAOImp(); 
	
	private String know;
	private String grade;
	private String type;
	private String version;
	private int index = 0;

	public static void main(String[] args) {
		System.out.println("resolve....");
		ResolveHtmlTest process = new ResolveHtmlTest();
		ResolveHtmlUtils htmlResolve = new ResolveHtmlUtils();
		JsoupUtils jsoup = new JsoupUtils();
		try {
			List<Result> resultList = process.dao.getRows("htmlPhy", "content");
			for(int i = 0;i < resultList.size();i++) {
				String html = new String(resultList.get(i).getValue("base".getBytes(), "content".getBytes()));
				htmlResolve.resolve(html);
			}
		}catch(Exception e) {
			e.printStackTrace();
		}
	}

	
//	private HBaseDao dao = new HBaseDAOImp();
	
//	public static void main(String[] args) {
//		System.out.println("resolve....");
//		ResolveHtmlTest process = new ResolveHtmlTest();
//		ResolveHtmlUtils htmlResolve = new ResolveHtmlUtils();
//		JsoupUtils jsoup = new JsoupUtils();
//		Result result = process.dao.getRow("Test","content");
//		System.out.println(new String(result.getValue("base".getBytes(), "content".getBytes())));
//		htmlResolve.resolve(new File("./text"));
//		PrintWriter pw = null;
//		try {
//			pw = new PrintWriter(new FileWriter("./result"));
//		} catch (IOException e) {
			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		List<Result> resultList = process.dao.getRows("Test","1");
//		System.out.println(resultList.size());
//		for(int i = 0;i < resultList.size();i++) {
//			String content = new String(resultList.get(i).getValue("base".getBytes(), "version".getBytes()));
//			System.out.println(content);
//			pw.write(content);
//			pw.flush();
//			pw.close();
//		}
//		try {
//			List<Result> resultList = process.dao.getRows("htmlPhy", "content");
////			List<Result> resultList1 = process.dao.getRows("htmlMath", "content");
////			List<Result> resultList2 = process.dao.getRows("htmlBio", "content");
////			List<Result> resultList3 = process.dao.getRows("htmlDiLi", "content");
////			System.err.println("---"+resultList.size());
////			System.err.println(resultList1.size());
////			resultList.addAll(resultList1);
////			System.err.println(resultList2.size());
////			System.err.println(resultList3.size());
//			for(int i = 0;i < resultList.size();i++) {
//				String html = new String(resultList.get(i).getValue("base".getBytes(), "content".getBytes()));
////				System.out.println(html);
//////				System.out.println(html.length());
////				htmlResolve.resolve(html);
////				List<String> optionList = jsoup.resolveOption("./Test.txt");
////				System.err.println(optionList.size());
//				htmlResolve.resolve(html);
//			}
//		}catch(Exception e) {
//			e.printStackTrace();
//		}
		
//	}

}
